<template>
    <a-card :bordered="false">
        <div class="table-operator">
            <a-button shape="round" size="small" type="primary" icon="plus" @click="handleEdit({},'packageForm','新增')">添加</a-button>
        </div>

        <LTable
        ref="packageList"
        size="middle"
        rowKey="keyId"
        :formAttributes="formAttributes"
        :columns="columns"
        axiosUrl="/KhyPackageController/page"
        :initOrder="[{'field': 'orderTime','val': 'desc'}]"
        :showPagination="true"
        :showQueryForm="true"
      >

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record,'packageForm','快递：'+record.packageNo)">详情</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete({keyId:record.keyId},'/KhyPackageController/del','packageList')">
                <a>删除</a>
            </a-popconfirm>
        </span>
        
    </LTable>
    <packageForm ref="packageForm" @close="refresh('packageList')" @ok="refresh('packageList')"></packageForm> 
    </a-card>
</template>

<script>
import LTable from '@/components/lt/LTable'
import request from '@/utils/request'
import packageForm from './packageForm'
import {SysMixin} from '@/mixins/SysMixin'
import defaultSettings from '@/config/defaultSettings'
export default {
    name:'packageList',
    components:{LTable,packageForm},
    mixins:[SysMixin],
    data(){
        return{
            initDictCodes:defaultSettings.数据字典.客运站下拉+','+defaultSettings.数据字典.快递状态下拉,
            defaultSettings,
            formAttributes:[
                {field:'packageNo',label:'快递单号',component:'input',condition:'like'},
                {field:'startStation',label:'发运站',component:'select',condition:'eq',dictCode:defaultSettings.数据字典.客运站下拉},
                {field:'endStation',label:'到达站',component:'select',condition:'eq',dictCode:defaultSettings.数据字典.客运站下拉},
                {field:'senderName',label:'托运人姓名',component:'input',condition:'like'},
                {field:'consigneeName',label:'收件人姓名',component:'input',condition:'like'},
                {field:'senderPhone',label:'托运人电话',component:'input',condition:'like'},
                {field:'consigneePhone',label:'收件人电话',component:'input',condition:'like'},
                {field:'orderTime',label:'下单时间',component:'time',condition:'between'},
                
            ],
         
            columns:[
                {
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                      return parseInt(index)+1;
                    }
                },
                {
                    title: '快递单号',
                    dataIndex: 'packageNo'
                },
                
                {
                    title: '发运站',
                    dataIndex: 'startStation',
                    customRender:(text)=>{
                        if(!text){
                            return ''
                        }else{
                            return this.dictText(defaultSettings.数据字典.客运站下拉,text)
                        }
                    }
                },
                {
                    title: '到达站',
                    dataIndex: 'endStation',
                    customRender:(text)=>{
                        if(!text){
                            return ''
                        }else{
                            return this.dictText(defaultSettings.数据字典.客运站下拉,text)
                        }
                    }
                },
                {
                    title: '托运人姓名',
                    dataIndex: 'senderName'
                },
                {
                    title: '收件人姓名',
                    dataIndex: 'consigneeName'
                },
                {
                    title: '托运人电话',
                    dataIndex: 'senderPhone'
                },
                {
                    title: '收件人电话',
                    dataIndex: 'consigneePhone'
                },
                {
                    title:'快递状态',
                    dataIndex:'packageState',
                    customRender:(text)=>{
                        if(!text){
                            return ''
                        }else{
                            return this.dictText(defaultSettings.数据字典.快递状态下拉,text)
                        }
                    }
                },
                {
                    title: '下单时间',
                    dataIndex: 'orderTime'
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    width: '120px',
                    scopedSlots: { customRender: 'action' }
                }
            ],
            
        }
    },
    created(){
       
    },
    methods:{
       
    }
}
</script>